/***************************************************************
Copyright ? wq Co., Ltd. 1998-2099. All rights reserved.
文件名	   : CySysKey.c
版本	   : V0.0
描述	   : CWP085 master 测试应用案例。
其他	   : 无
日志	   : 初版V0.0 2025/01/17 
***************************************************************/

/*******************************************************************************
* Include 
*******************************************************************************/ 
#include "CySysKey.h"
#include "CySysMaster.h"
#include "application.h"
#include "app_Uart.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/*******************************************************************************
* Valuse 
*******************************************************************************/ 
static uint8_t WarmAlarm=70;
static uint8_t ColdAlarm=20;
uint8_t KeyFunc=0;
/*定义整个系统按键的操作可能性对应结构体*/
KeyMode_TypeDef  KeyTab[]=
{
    { 0 , 0 , 1 , 0 , 5 , 0 , Key_Function0  }, // 
    { 1 , 1 , 2 , 1 , 1 , 7 , Key_Function1  }, // 查询actual
    { 2 , 2 , 3 , 2 , 2 , 7 , Key_Function2  }, // 查询Offset
    { 3 , 3 , 4 , 3 , 2 , 7 , Key_Function3  }, // 查询setpoint
    { 4 , 4 , 5 , 4 , 3 , 7 , Key_Function4  }, // 查询warm 
    { 5 , 5 , 1 , 5 , 4 , 7 , Key_Function5  }, // 查询cold
    { 6 , 6 , 6 , 0 , 6 , 7 , Key_Function6  }, // 确定后灭底下灯
    { 7 , 7 , 7 , 0 , 7 , 7 , Key_Function7  }, // 设置
};


/*******************************************************************************
* Function Name  : Key_Progress
* Description    : key scan and progress
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
unsigned char  KeysNow=0;
unsigned char  KeyDelay=0;
/*******************************************************************************
* Function Name  : Touch_Key_Scan()
* Description    : key scan
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Touch_Key_Scan(void)
{
    uint8_t arr[]={0x07};
    uint8_t sendBuff[4]={0x5A,0xA5,0x00,0x00};
    static uint8_t KeysGetOld=0;
    WriteCommandPacket(SLAVER_ADDRESS,arr,1,I2C_I2C_MODE_COMPLETE_XFER);
    CyDelay(1);
    ReadStatusPacket(SLAVER_ADDRESS, &CySysCMD.mCMD[7], 1, I2C_I2C_MODE_COMPLETE_XFER); 
    //KeyCode_Temp=CySysCMD.mCMD[7];
//    if((KeysGetOld!=CySysCMD.mCMD[7]))
//    {
//        KeysGetOld=CySysCMD.mCMD[7];
//        sendBuff[2]=KeysGetOld;
//        sendBuff[3]=App_CRC8_Check(sendBuff,3);
//        App_UART_Send(sendBuff, 4); 
//    }
    if(CySysCMD.mCMD[7]!=0)
    {
         sendBuff[2]=CySysCMD.mCMD[7];
         sendBuff[3]=App_CRC8_Check(sendBuff,3);
         App_UART_Send(sendBuff, 4); 
    }
    
}

/*******************************************************************************
* Function Name  : Key_Progress()
* Description    : key scan -progress
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Key_Progress(void)
{
    uint8_t arr[]={0x07};
    uint8_t arrt[3]={0x04,0,0};
    unsigned char KeyCode_Temp=0;
    static uint8_t KeysGetOld=0;
    WriteCommandPacket(SLAVER_ADDRESS,arr,1,I2C_I2C_MODE_COMPLETE_XFER);
    CyDelay(1);
    ReadStatusPacket(SLAVER_ADDRESS, &CySysCMD.mCMD[7], 1, I2C_I2C_MODE_COMPLETE_XFER); 
    KeyCode_Temp=CySysCMD.mCMD[7];
//    if(CySysCMD.bits.TP4==1)
//    { CySysCMD.bits.LEDB3=1;}
//    else
//    {CySysCMD.bits.LEDB3=0;}
//    
//    if(CySysCMD.bits.TP1==1)
//    {CySysCMD.bits.LEDR5=1;}
//    else
//    {CySysCMD.bits.LEDR5=0;}
//    
//    if(CySysCMD.bits.TP3==1)
//    {CySysCMD.bits.LEDB4=1;}
//    else
//    {CySysCMD.bits.LEDB4=0;}
//    
//    if(CySysCMD.bits.TP2==1)
//    {CySysCMD.bits.LEDB1=1;}
//    else
//    {CySysCMD.bits.LEDB1=0;}
//    
//    if(CySysCMD.bits.TP5==1)
//    {CySysCMD.bits.LEDB2=1;}
//    else
//    {CySysCMD.bits.LEDB2=0;}
//   // printf("CySysCMD.mCMD[7]:%d\r\n",CySysCMD.mCMD[7]);
    if(KeysGetOld!=CySysCMD.mCMD[7])
    {
        KeysGetOld=CySysCMD.mCMD[7];
        arrt[1]=CySysCMD.mCMD[4];arrt[2]=CySysCMD.mCMD[5];
        WriteCommandPacket(SLAVER_ADDRESS,arrt,3,I2C_I2C_MODE_COMPLETE_XFER);
    }
    //printf("KeyCode_Temp:%d\r\n",KeyCode_Temp);
        /*消抖*/
        if( KeyCode_Temp != 0 )//按键有操作
        {
            if( KeysNow == 0 )
            {
                KeysNow = KeyCode_Temp;
                KeyDelay = 0;
            }
            else
            {
                /*若按键没有松开，KeyCode_Temp会等于KeysNow*/
                if(KeysNow == KeyCode_Temp )
                {
                  KeyDelay++;
                  if(KeyDelay >5)
                  {
                    /*这里的计数，可用于判断是否长按*/
                    KeyDelay = 6;
                  }
                }
                else
                {
                  /*若KeyCode_Temp不等于KeysNow，则键值改变*/
                  /*重新进行扫描消抖操作*/
                   KeysNow = KeyCode_Temp ;
                    KeyDelay = 0 ;
                }
            }
        }
        else
        {
          /*因为每次进来KeyCode_Temp都会清0，若按键没有操作，则KeyCode_Temp=0*/
          /*KeyDelay这个标志，一是消抖，而是可以判断是否长按，若是*/
          //printf("KeyDelay:%d\r\n",KeyDelay);
          if(KeyDelay>=2)
          {
             User_Key_Progress();
          }    
          KeysNow = 0;
          KeyDelay = 0;
        }    
   
}

/*******************************************************************************
* Function Name  : Key_Function0
* Description    : key scan -progress
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Key_Function0(void)
{
    CySysFlag.bits.Fun8state=0;
    if(CySysFlag.bits.CycSysPage==0)
    {
        clearArry(&(CySysCMD.mCMD[1]));
        CySysCMD.mCMD[1]=0xDA;
        CySysCMD.mCMD[2]=0x5E;
        CySysCMD.mCMD[3]=0xFA;
        CySysCMD.bits.LEDG1=1;
    }
    else if(CySysFlag.bits.CycSysPage==1)
    {
         Key_Function1();
    }
    else if(CySysFlag.bits.CycSysPage==2)
    {
         Key_Function2();
    }
    else if(CySysFlag.bits.CycSysPage==3)
    {
        Key_Function3();
    }
    else if(CySysFlag.bits.CycSysPage==4)
    {
        Key_Function4();
    }
    else if(CySysFlag.bits.CycSysPage==5)
    {
        Key_Function5();
    }
}
/*******************************************************************************
* Function Name  : Key_Function1()
* Description    : key scan -progress   //check
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Key_Function1(void)        
{
    

    clearArry(&(CySysCMD.mCMD[1]));
    //CySysFlag.bits.Fun8state=0;
    CySysFlag.bits.CycSysPage=1;
    switch(CySysFlag.bits.Fun1state)
    {
        case 0:
        {
            CySysCMD.bits.LEDWG1=1;
            CySysCMD.bits.LEDWG2=1;
            CySysCMD.bits.LEDWB3=1;
            CySysCMD.bits.LEDWC3=1;
            CySysCMD.bits.LEDWD3=1;
            CySysCMD.bits.LEDG1=1;
            break;
        }
        case 1:
        {
            CySysCMD.bits.LEDWG1=1;
            CySysCMD.bits.LEDWG2=1;
            CySysCMD.bits.LEDWB3=1;
            CySysCMD.bits.LEDWC3=1;
            CySysCMD.bits.LEDWG3=1;
            CySysCMD.bits.LEDWF3=1;
            CySysCMD.bits.LEDWE3=1;
            CySysCMD.bits.LEDG1=1;
            break;
        }
        case 2:
        {
            CySysCMD.bits.LEDWG1=1;
            CySysCMD.bits.LEDWB2=1;
            CySysCMD.bits.LEDWC2=1;
            CySysCMD.bits.LEDWG2=1;
            CySysCMD.bits.LEDWF2=1;
            CySysCMD.bits.LEDWE2=1;
            CySysCMD.bits.LEDWB3=1;
            CySysCMD.bits.LEDWC3=1;
            CySysCMD.bits.LEDWG3=1;
            CySysCMD.bits.LEDWF3=1;
            CySysCMD.bits.LEDWE3=1;
            
            CySysCMD.bits.LEDR2=1;
            break;
        }
        case 3:
        {
            CySysCMD.bits.LEDWB1=1;
            CySysCMD.bits.LEDWC1=1;
            CySysCMD.bits.LEDWG1=1;
            CySysCMD.bits.LEDWF1=1;
            CySysCMD.bits.LEDWE1=1;
            
            CySysCMD.bits.LEDWB2=1;
            CySysCMD.bits.LEDWC2=1;
            CySysCMD.bits.LEDWG2=1;
            CySysCMD.bits.LEDWF2=1;
            CySysCMD.bits.LEDWE2=1;
            
            CySysCMD.bits.LEDWB3=1;
            CySysCMD.bits.LEDWC3=1;
            CySysCMD.bits.LEDWG3=1;
            CySysCMD.bits.LEDWF3=1;
            CySysCMD.bits.LEDWE3=1;
            
            CySysCMD.bits.LEDR2=1;
            break;
        }
       default:
            break; 
    }
       
        CySysCMD.bits.LEDW6=1;


}
/*******************************************************************************
* Function Name  : Key_Function2()
* Description    : key scan -progress   //actual
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Key_Function2(void)
{
    
    clearArry(&(CySysCMD.mCMD[1]));
    CySysFlag.bits.CycSysPage=2;
    
     
    CySysCMD.bits.LEDW8=1;
    CySysCMD.bits.LEDWB2=1;
    CySysCMD.bits.LEDWC2=1;
    CySysCMD.bits.LEDWD2=1;
    CySysCMD.bits.LEDG1=1;
    Num_Display_WA3(CySysFlag.bits.Fun2state);
    

}
/*******************************************************************************
* Function Name  : Key_Function3()
* Description    : key scan -progress
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Key_Function3(void)
{
    clearArry(&(CySysCMD.mCMD[1]));
    CySysFlag.bits.CycSysPage=3;
    CySysCMD.bits.LEDW7=1;
    CySysCMD.mCMD[3]=0xBC;
    CySysCMD.mCMD[2]=0xDE;
    CySysCMD.bits.LEDG1=1;
    Num_Display_WA3(CySysFlag.bits.Fun3state);

}
/*******************************************************************************
* Function Name  : Key_Function4()
* Description    : key scan -progress
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Key_Function4(void)
{
    static uint8_t display_warm=0;
    clearArry(&(CySysCMD.mCMD[1]));
    CySysFlag.bits.CycSysPage=4;
    //srand(time(NULL));
    display_warm= 20+(rand() % 80);
    CySysCMD.bits.LEDW9=1;
    if(display_warm<100)
    {
        if(display_warm>10)
        {
            CySysCMD.mCMD[3]=0;
            Num_Display_WA2((display_warm/10)%10);
            Num_Display_WA3(display_warm%10);
        }
        else
        {
            CySysCMD.mCMD[2]=0;
            CySysCMD.mCMD[3]=0;
            Num_Display_WA3(display_warm);
        }
    }
    else
    {
        Num_Display_WA1(1);
        CySysCMD.mCMD[1]=0xDE;
        CySysCMD.mCMD[2]=0xDE;
    }
    if(display_warm>WarmAlarm)
    {CySysCMD.bits.LEDR3=1;CySysCMD.bits.LEDG1=0;}
    else
    {CySysCMD.bits.LEDR3=0;CySysCMD.bits.LEDG1=1;}

}
/*******************************************************************************
* Function Name  : Key_Function5()
* Description    : key scan -progress
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Key_Function5(void)
{
    static uint8_t display_cold=0;
    clearArry(&(CySysCMD.mCMD[1]));
    CySysFlag.bits.CycSysPage=5;
    //srand(time(NULL));
    display_cold= 1+(rand() % 40);
    CySysCMD.bits.LEDW9=1;
    CySysCMD.mCMD[3]=0x20;
    if(display_cold>10)
    {
        Num_Display_WA2((display_cold/10)%10);
        Num_Display_WA3(display_cold%10);
    }
    else
    {
         CySysCMD.mCMD[2]=0xDE;
         Num_Display_WA3(display_cold);
    }
    if(display_cold>ColdAlarm)
    {CySysCMD.bits.LEDR3=1;CySysCMD.bits.LEDG1=0;}
    else
    {CySysCMD.bits.LEDR3=0;CySysCMD.bits.LEDG1=1;}
    

}
/*******************************************************************************
* Function Name  : Key_Function6()
* Description    : key scan -progress
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Key_Function6(void)
{


}

/*******************************************************************************
* Function Name  : Key_Function8()
* Description    : key scan -progress
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Key_Function7(void)
{
    clearArry(&(CySysCMD.mCMD[1])); 
    CySysFlag.bits.Fun8state=1;
    if(CySysFlag.bits.CycSysPage==1)
    {
        CySysCMD.bits.LEDW6=1;
        CySysCMD.bits.LEDW5=1;
        if(KeysNow==0x04)
        {
            if(CySysFlag.bits.Fun1state<3)
            {
                CySysFlag.bits.Fun1state++;
            }
            else
            {
                CySysFlag.bits.Fun1state=0;
            }
        }
        else if(KeysNow==0x10)
        {
            if(CySysFlag.bits.Fun1state>0)
            {
                CySysFlag.bits.Fun1state--;
            }
            else
            {
                CySysFlag.bits.Fun1state=3;
            }
        }
        Num_Display_WA3(CySysFlag.bits.Fun1state);   
    }
    else if(CySysFlag.bits.CycSysPage==2)
    {
        CySysCMD.bits.LEDW8=1;
        CySysCMD.bits.LEDW3=1;
         if(KeysNow==0x04)
        {
            if(CySysFlag.bits.Fun2state<3)
            {
                CySysFlag.bits.Fun2state++;
            }
            else
            {
                CySysFlag.bits.Fun2state=0;
            }
        }
        else if(KeysNow==0x10)
        {
            if(CySysFlag.bits.Fun2state>0)
            {
                CySysFlag.bits.Fun2state--;
            }
            else
            {
                CySysFlag.bits.Fun2state=3;
            }
        }
        switch (CySysFlag.bits.Fun2state)
        {
            case 0:
                CySysCMD.mCMD[8]=0x06;
                break;
            case 1:
                CySysCMD.mCMD[8]=0x10;
                break;
            case 2:
                CySysCMD.mCMD[8]=0x14;
                break;
            case 3:
                CySysCMD.mCMD[8]=0x18;
                break;
            default:
                break;
        }
        Num_Display_WA3(CySysFlag.bits.Fun2state); 
    }
    else if(CySysFlag.bits.CycSysPage==3)
    {
        CySysCMD.bits.LEDW7=1;
        CySysCMD.bits.LEDW4=1;
        CySysCMD.mCMD[3]=0xBC;
        CySysCMD.mCMD[2]=0xDE;
        if(KeysNow==0x04)
        {
            if(CySysFlag.bits.Fun3state<5)
            {
                CySysFlag.bits.Fun3state++;
            }
            else
            {
                CySysFlag.bits.Fun3state=0;
            }
        }
        else if(KeysNow==0x10)
        {
            if(CySysFlag.bits.Fun3state>0)
            {
                CySysFlag.bits.Fun3state--;
            }
            else
            {
                CySysFlag.bits.Fun3state=5;
            }
        }
         Num_Display_WA3(CySysFlag.bits.Fun3state); 
    }
    else if(CySysFlag.bits.CycSysPage==4)
    {
        CySysCMD.bits.LEDW9=1;
        CySysCMD.bits.LEDW1=1;
        if(KeysNow==0x04)
        {
            if(WarmAlarm<99)
            {
                WarmAlarm++;
            }
            else
            {
                 WarmAlarm=0;
            }
        }
        else if(KeysNow==0x10)
        {
            if(WarmAlarm>0)
            {
                WarmAlarm--;
            }
            else
            {
                WarmAlarm=99;
            }
        }
        if(WarmAlarm<100)
        {
            if(WarmAlarm>10)
            {
                CySysCMD.mCMD[3]=0;
                Num_Display_WA2((WarmAlarm/10)%10);
                Num_Display_WA3(WarmAlarm%10);
            }
            else
            {
                CySysCMD.mCMD[2]=0;
                CySysCMD.mCMD[3]=0;
                Num_Display_WA3(WarmAlarm);
            }
        }
        else
        {
            Num_Display_WA1(1);
            CySysCMD.mCMD[1]=0xDE;
            CySysCMD.mCMD[2]=0xDE;
        }
        
        
    }
    else if(CySysFlag.bits.CycSysPage==5)
    {
        CySysCMD.bits.LEDW9=1;
        CySysCMD.bits.LEDW2=1;
        if(KeysNow==0x04)
        {
            if(ColdAlarm<40)
            {
                ColdAlarm++;
            }
            else
            {
                ColdAlarm=0;
            }
        }
        else if(KeysNow==0x10)
        {
            if(ColdAlarm>0)
            {
                ColdAlarm--;
            }
            else
            {
                 ColdAlarm=40;
            }
        }
        if(ColdAlarm>=10)
        {
            Num_Display_WA2((ColdAlarm/10)%10);
            Num_Display_WA3(ColdAlarm%10);
        }
        else
        {
             CySysCMD.mCMD[2]=0xDE;
             Num_Display_WA3(ColdAlarm);
        }
        
        
    
    }

   
    
    

}
/*******************************************************************************
* Function Name  : uint8_t GetPage_Function(void)
* Description    : 获取当前页
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
uint8_t GetPage_Function(void)
{
    return CySysFlag.bits.CycSysPage;
}
/*******************************************************************************
* Function Name  :void clearArry(uint8_t * arr)
* Description    : 清除点灯数组数据
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void clearArry(uint8_t * arr)
{
    for(int i=0;i<LED_CONSIZE;i++)
    {
        arr[i]=0;
    }
}
//比较点灯
uint8_t array_equadt(uint8_t * arr1, uint8_t * arr2,uint8_t size)
{
        for(uint8_t i=0;i<size;i++)
       {
             if(arr2[i]!=arr1[i])
            {
                  return 0;
            }
       }
      return 1;
}
//拷贝更新点灯数据
void array_copydt(uint8_t * arr1, uint8_t * arr2,uint8_t size)
{
    for(uint8_t i=0;i<size;i++)
    {
        if(arr2[i]!=arr1[i])
            {
                  arr1[i]=arr2[i];
            }
    }

}

/*******************************************************************************
* Function Name  : User_Key_Progress
* Description    : 按键识别
* Input          : None
* Output         : None
* Return         : None
* Note           : None
*******************************************************************************/
 void User_Key_Progress(void)
{
   
         // void (*KeyFuncPtr)();
            switch( KeysNow )
            {
              case 0x04 :
                     KeyFunc = KeyTab[KeyFunc].KeyUpState;    //get up key next status
                     break;
              case 0x02:
                    KeyFunc = KeyTab[KeyFunc].KeyMtState;    //get down key next status
                    CySysFlag.bits.muteChange^=1;
                    break;
              case 0x08 :
                    KeyFunc = KeyTab[KeyFunc].KeyEnState;    //get enter key next status
                    break;
              case 0x10 :
                    KeyFunc = KeyTab[KeyFunc].KeyDnState;  //get return key next status
                    break;
              case 0x20 :
                    KeyFunc = KeyTab[KeyFunc].KeyStstate;  //get return key next status
                    break;
              default:
                    return;
            }
            KeyTab[KeyFunc].mKeyFunciton();

         // (*KeyFuncPtr)();
          KeysNow = 0; 

}
/*******************************************************************************
* Function Name  : void CycSystem_Display(void)
* Description    : 显示
* Input          : None
* Output         : None
* Return         : None
* Note           : None
*******************************************************************************/ 
void CycSystem_Display(void)
{
     static uint8_t arry[7]={0x01,0,0};
     static uint8_t arrtmp[7]={0x01,0,0};
     static uint8_t brig[2]={0x08,0};
     static uint8_t sendreg[2]={0x00};

     array_copydt(arry,CySysCMD.mCMD,7);
    
    
    
    
  //客户的板子上位机控制不了，怀疑它的板子芯片从机不支持连续的地址读写。只能一对一，故此修改试一下
  #if 0  
    if(!array_equadt(arrtmp,arry,7))
    {
        array_copydt(arrtmp,arry,7);
        WriteCommandPacket(SLAVER_ADDRESS,arrtmp,7,I2C_I2C_MODE_COMPLETE_XFER);
    }
    if( brig[1]!=CySysCMD.mCMD[8])
    {
        brig[1]=CySysCMD.mCMD[8];
        WriteCommandPacket(SLAVER_ADDRESS,brig,2,I2C_I2C_MODE_COMPLETE_XFER);
    }
  #endif
    if(arrtmp[1]!=arry[1])
    {
        arrtmp[1]=arry[1];
        sendreg[0]=0x01;sendreg[1]=arrtmp[1];
        WriteCommandPacket(SLAVER_ADDRESS,sendreg,2,I2C_I2C_MODE_COMPLETE_XFER);
        
    }
    if(arrtmp[2]!=arry[2])
    {
        arrtmp[2]=arry[2];
        sendreg[0]=0x02;sendreg[1]=arrtmp[2];
        WriteCommandPacket(SLAVER_ADDRESS,sendreg,2,I2C_I2C_MODE_COMPLETE_XFER);
        
    }
    if(arrtmp[3]!=arry[3])
    {
        arrtmp[3]=arry[3];
        sendreg[0]=0x03;sendreg[1]=arrtmp[3];
        WriteCommandPacket(SLAVER_ADDRESS,sendreg,2,I2C_I2C_MODE_COMPLETE_XFER);
        
    }
    if(arrtmp[4]!=arry[4])
    {
        arrtmp[4]=arry[4];
        sendreg[0]=0x04;sendreg[1]=arrtmp[4];
        WriteCommandPacket(SLAVER_ADDRESS,sendreg,2,I2C_I2C_MODE_COMPLETE_XFER);
        
    }
    if(arrtmp[5]!=arry[5])
    {
        arrtmp[5]=arry[5];
        sendreg[0]=0x05;sendreg[1]=arrtmp[5];
        WriteCommandPacket(SLAVER_ADDRESS,sendreg,2,I2C_I2C_MODE_COMPLETE_XFER);
        
    }
     if(arrtmp[6]!=arry[6])
    {
        arrtmp[6]=arry[6];
        sendreg[0]=0x06;sendreg[1]=arrtmp[6];
        WriteCommandPacket(SLAVER_ADDRESS,sendreg,2,I2C_I2C_MODE_COMPLETE_XFER);
        
    }
     if( brig[1]!=CySysCMD.mCMD[8])
    {
        brig[1]=CySysCMD.mCMD[8];
        sendreg[0]=0x08;sendreg[1]= brig[1];
        WriteCommandPacket(SLAVER_ADDRESS,sendreg,2,I2C_I2C_MODE_COMPLETE_XFER);
    }
    





}

/*******************************************************************************
* Function Name  : void Num_Display_WA1(uint8_t index)
* Description    : 显示
* Input          : None
* Output         : None
* Return         : None
* Note           : None
*******************************************************************************/ 
void Num_Display_WA1(uint8_t index)
{
    switch (index)
    {
        case 0:
            CySysCMD.mCMD[3]=0xDE;
             break;
        case 1:
            CySysCMD.mCMD[3]=0x42;
            break;
        case 2:
            CySysCMD.mCMD[3]=0xEC;
            break;
        case 3:
            CySysCMD.mCMD[3]=0xE6;
            break;
        case 4:
            CySysCMD.mCMD[3]=0x72;
            break;
        case 5:
            CySysCMD.mCMD[3]=0xB6;
            break;
        case 6:
            CySysCMD.mCMD[3]=0xBE;
            break;
        case 7:
            CySysCMD.mCMD[3]=0xC2;
            break;
        case 8:
            CySysCMD.mCMD[3]=0xFE;
            break;
        case 9:
             CySysCMD.mCMD[3]=0xF6;
            break;
        default:
             CySysCMD.mCMD[3]=0;
             break; 
    }

}
/*******************************************************************************
* Function Name  : void Num_Display_WA1(uint8_t index)
* Description    : 显示
* Input          : None
* Output         : None
* Return         : None
* Note           : None
*******************************************************************************/ 
void Num_Display_WA2(uint8_t index)
{
    switch (index)
    {
        case 0:
            CySysCMD.mCMD[2]=0xDE;
             break;
        case 1:
            CySysCMD.mCMD[2]=0x42;
            break;
        case 2:
            CySysCMD.mCMD[2]=0xEC;
            break;
        case 3:
            CySysCMD.mCMD[2]=0xE6;
            break;
        case 4:
            CySysCMD.mCMD[2]=0x72;
            break;
        case 5:
            CySysCMD.mCMD[2]=0xB6;
            break;
        case 6:
            CySysCMD.mCMD[2]=0xBE;
            break;
        case 7:
            CySysCMD.mCMD[2]=0xC2;
            break;
        case 8:
            CySysCMD.mCMD[2]=0xFE;
            break;
        case 9:
             CySysCMD.mCMD[2]=0xF6;
            break;
        default:
             CySysCMD.mCMD[2]=0;
             break; 
    }

}

/*******************************************************************************
* Function Name  : void Num_Display_WA3(uint8_t index)
* Description    : 显示
* Input          : None
* Output         : None
* Return         : None
* Note           : None
*******************************************************************************/ 
void Num_Display_WA3(uint8_t index)
{
    switch (index)
    {
        case 0:
            CySysCMD.mCMD[1]=0xDE;
             break;
        case 1:
            CySysCMD.mCMD[1]=0x42;
            break;
        case 2:
            CySysCMD.mCMD[1]=0xEC;
            break;
        case 3:
            CySysCMD.mCMD[1]=0xE6;
            break;
        case 4:
            CySysCMD.mCMD[1]=0x72;
            break;
        case 5:
            CySysCMD.mCMD[1]=0xB6;
            break;
        case 6:
            CySysCMD.mCMD[1]=0xBE;
            break;
        case 7:
            CySysCMD.mCMD[1]=0xC2;
            break;
        case 8:
            CySysCMD.mCMD[1]=0xFE;
            break;
        case 9:
             CySysCMD.mCMD[1]=0xF6;
            break;
        default:
             CySysCMD.mCMD[2]=0;
             break; 
    }

}

